package com.yztc.ui.cook.categoryinfo;

import com.yztc.bean.cook.CategoryInfoBean;
import com.yztc.http.RetrofitService;
import com.yztc.ui.cook.jiekou.CookOnloadListener3;
import com.yztc.utils.HttpHelper;

import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2016/10/10.
 */

public class CategoryInfoModle implements CategoryInfoConstract.Modle {
    public static String a="1";
    @Override
    public void getCategoryInfo(String baseUrl, final CookOnloadListener3 listener) {
        Observable observable = (Observable) HttpHelper
                .getInstance()
                .getRetrofit(baseUrl)
                .create(RetrofitService.class)
                .getCategoryInfoBean(a);
        observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<CategoryInfoBean>() {

                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.onFailure(e);
                    }

                    @Override
                    public void onNext(CategoryInfoBean categoryInfoBean) {
                        listener.onSuccess(categoryInfoBean);
                    }

                });
    }
}
